﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="/JqueryPlug/dtGrid/jquery.dtGrid.css" rel="stylesheet">
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/CSS/Base/Button.css" rel="stylesheet">


    <script src="/Scripts/jquery-1.11.2.min.js"></script>

    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/JqueryPlug/dtGrid/jquery.dtGrid.js"></script>
    <script src="/Scripts/SZHLCommon.js"></script>
    <script type="text/javascript">
        var strUserName = ComFunJS.getQueryString("userName");
        var branchNo = ComFunJS.getQueryString("branchNo");
        if (strUserName != "") {
            var model = avalon.define({
                $id: "YGGLAdd",
                RoleData: [],
                UserData: { "UserName": "", "UserRealName": "", "UserPass": "", "IsUse": "Y", "zhiwu": "", "mobphone": "", "mailbox": "", "mailbox": "", "UserSign": "", "BranchName": "", "BranchCode": "" },
                UserEdit: function () {
                    var modelValue = JSON.stringify(model.UserData.$model);
                    $.post("/API/SZHLAPI.ashx", { Action: "ADDUSER", P1: modelValue },
                    function (result) {
                        if ($.trim(result.ErrorMsg) != "") {
                            ComFunJS.winwarning(result.ErrorMsg);
                        }
                    });
                },
                SetFrameHeight: function (framename) {
                    var oFrm = document.getElementById(framename);
                    oFrm.onload = oFrm.onreadystatechange = function () {
                        if (this.readyState && this.readyState != 'complete') return;
                        else {
                            var mainheight = $("#dvContent").height() - 45;
                            $("#" + framename).height(mainheight);
                            $("#mastmenu").height(mainheight);
                            $(window.frames[framename].document).find(".maindiv").css({ height: mainheight + "px", overflow: "auto" });
                        }
                    }
                }
            });
        }
        avalon.ready(function () {
            //获取主要菜单
            $.getJSON('/API/SZHLAPI.ashx?Action=GETROLE', { "P1": "职务角色", "P2": branchNo }, function (resultData) {
                model.RoleData = resultData.Result;
                model.UserData.BranchName = resultData.Result1.DeptName;
                model.UserData.BranchCode = resultData.Result1.DeptCode;
                model.UserData.zhiwu = resultData.Result[0].RoleName;

            })
            if (strUserName != null) {

                //人员信息
                $.getJSON('/API/SZHLAPI.ashx?Action=GETUSERBYUSERNAME', { "P1": strUserName }, function (resultData) {
                    model.UserData = resultData.Result;
                    model.UserData.BranchName = resultData.Result1;
                })
            }
        })
    </script>
</head>
<body ms-controller="YGGLAdd">
    <div class="container-fluid maindiv" style="margin: 20px 20px 50px 20px">

        <div class="form-horizontal">

            <div class="form-group">
                <label for="branchName" class="col-xs-3 control-label text-right">所属部门</label>
                <div class="col-xs-6">
                    <label id="branchName" class="control-label" ms-duplex="UserData.BranchName">{{UserData.BranchName}}</label>
                </div>
            </div>
            <div class="form-group">
                <label for="userName" class="col-xs-3 control-label text-right">用户名称</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" ms-duplex="UserData.UserName" id="userName" placeholder="请输入用户名称" />
                </div>
            </div>
            <div class="form-group">
                <label for="userRealName" class="col-xs-3 control-label text-right">用户真实名称</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" ms-duplex="UserData.UserRealName" id="userRealName" placeholder="请输入用户真实名称" />
                </div>
            </div>
            <div class="form-group">
                <label for="userPass" class="col-xs-3 control-label text-right">用户密码</label>
                <div class="col-xs-6">
                    <input type="password" class="form-control" ms-duplex="UserData.UserPass" id="userPass" placeholder="请输入用户密码" />
                </div>
            </div>
            <div class="form-group">
                <label for="isUse" class="col-xs-3 control-label text-right">是否可用</label>
                <div class="col-xs-6">
                    <select id="isUse" class="form-control" ms-duplex="UserData.IsUse">
                        <option value="Y" ms-attr-selected="UserData.IsUse=='Y'?'selected':''">是</option>
                        <option value="N" ms-attr-selected="UserData.IsUse=='N'?'selected':''">否</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="zhiwu" class="col-xs-3 control-label text-right">职务</label>
                <div class="col-xs-6">
                    <select id="zhiwu" class="form-control" ms-duplex="UserData.zhiwu">
                        <option ms-attr-value="item.RoleName" ms-repeat-item="RoleData">{{item.RoleName}}</option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label for="Telphone" class="col-xs-3 control-label text-right">手机号码</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" ms-duplex="UserData.mobphone" id="Telphone" placeholder="请输入手机号码" />
                </div>
            </div>
            <div class="form-group">
                <label for="Email" class="col-xs-3 control-label text-right">邮箱</label>
                <div class="col-xs-6">
                    <input type="text" class="form-control" ms-duplex="UserData.mailbox" id="Email" placeholder="请输入邮箱" />
                </div>
            </div>
            <div class="form-group">
                <label for="UserSign" class="col-xs-3 control-label text-right">员工职责</label>
                <div class="col-xs-7">
                    <textarea ms-duplex="UserData.Usersign" rows="8" id="UserSign" class="form-control" placeholder="请输入员工职责"></textarea>
                </div>
            </div>
            <div class="form-group  ">
                <div class="col-xs-12 text-center ">
                    <input type="button" id="btnAdd" value="保存" ms-click="UserEdit()" class="btn btn-lg btn-success" />
                </div>
            </div>
        </div>
    </div>
</body>
</html>
